#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <iterator>
#include <algorithm>

using std::cout;
using std::endl;
using std::vector;
using std::list;
using std::set;
using std::back_inserter;
using std::back_insert_iterator;
using std::front_inserter;
using std::front_insert_iterator;
using std::inserter;
using std::insert_iterator;
using std::copy;
using std::ostream_iterator;

void test()
{
    vector<int> vec = {1, 5, 9, 7, 4};
    list<int> lst = {11, 44, 88, 55};

    //将list中的元素插入到vector的尾部，最后遍历vector
    copy(lst.begin(), lst.end(), back_inserter(vec));
    copy(vec.begin(), vec.end(), 
         ostream_iterator<int>(cout, "  "));
    cout << endl;

    cout << endl << endl;
    //将vector中的元素插入到list的头部，最后遍历list
    copy(vec.begin(), vec.end(), front_inserter(lst));
    copy(lst.begin(), lst.end(), 
         ostream_iterator<int>(cout, "  "));
    cout << endl;

    cout << endl << endl;
    //将vector中的元素插入到set中，最后遍历set
    set<int> number = {1, 4, 9, 6, 100, 33, 55};
    auto it = number.begin();
    copy(vec.begin(), vec.end(), inserter(number, it));
    copy(number.begin(), number.end(), 
         ostream_iterator<int>(cout, "  "));
    cout << endl;


}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

